home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 10 / AACD 10.iso / AACD / Resources / General / ProNET / src / utilities / pronet-talk.s < prev   
Text File  |  1996-10-01  |  7KB  |  372 lines

  1. *
  2. * pronet-talk.s
  3. *
  4.  
  5. CSI        equ    27+128
  6.  
  7.         include    "A:OSmacros.i"
  8.         include    "exec/exec.i"
  9.         include    "intuition/intuition.i"
  10.         include    "p:include/devices/pronet.i"
  11.         include    "exec_lib.i"
  12.         include    "intuition_lib.i"
  13.  
  14. j        bsr    dec2long    * UNIT as Argument
  15.         move.l    d1,unit
  16.  
  17.         lea    wintitle2mod(pc),a0
  18.         move.l    unit(pc),d0
  19.         bsr    long2dec
  20.         clr.b    (a0)+
  21.  
  22.         move.l    4.w,a6
  23.         lea    intname(pc),a1
  24.         LIBCALL    OldOpenLibrary
  25.         move.l    d0,intbase
  26.  
  27.         bsr    initconsole
  28.         tst.w    d0
  29.         bne    noconsole
  30.  
  31.         bsr    startpronet
  32.         tst.w    d0
  33.         bne    nopronet
  34.         move.l    intbase(pc),a6
  35.         move.l    window(pc),a0
  36.         lea    wintitle2(pc),a1
  37.         move.l    a1,a2
  38.         LIBCALL    SetWindowTitles
  39.  
  40.         bsr    Wait4Message
  41.  
  42.         bsr    stoppronet
  43.  
  44. nopronet    bsr    closeconsole
  45.  
  46. noconsole    move.l    intbase(pc),a1
  47.         move.l    4.w,a6
  48.         LIBCALL    CloseLibrary
  49.         moveq    #0,d0
  50.         rts
  51.  
  52.         dc.b    "$VER: pronet-talk 37.1 (1.10.96)",13,10,0
  53.         even
  54.  
  55. initconsole    move.l    intbase(pc),a6        ;Window öffnen
  56.         cmp.w    #36,LIB_VERSION(a6)
  57.         bcs.s    .nokick2
  58.         lea    wbname(pc),a0
  59.         LIBCALL    LockPubScreen
  60.         move.l    d0,wbscreen
  61.         beq    icnoscr
  62.         move.l    d0,a0
  63.         moveq    #0,d1
  64.         move.b    sc_WBorTop(a0),d1
  65.         add.b    sc_WBorBottom(a0),d1
  66.         add.w    sc_RastPort+rp_TxHeight(a0),d1
  67.         add.w    #2+100,d1
  68.         move.w    d1,newwindow+6
  69. .nokick2    lea    newwindow(pc),a0
  70.         LIBCALL    OpenWindow
  71.         move.l    d0,window
  72.         beq    icnowin
  73.  
  74.         moveq    #48,d0            ;Console-Device öffnen
  75.         bsr    GetIORequest
  76.         move.l    d0,conreadio
  77.         beq    nodevblock1
  78.         moveq    #48,d0
  79.         bsr    GetIORequest
  80.         move.l    d0,conwriteio
  81.         beq    nodevblock2
  82.         move.l    conreadio(pc),a1
  83.         move.l    window(pc),IO_DATA(a1)
  84.         lea    consolename(pc),a0
  85.         moveq    #0,d0
  86.         moveq    #0,d1
  87.         move.l    4.w,a6
  88.         LIBCALL    OpenDevice
  89.         tst.l    d0
  90.         bne    nocondev
  91.         move.l    conreadio(pc),a0
  92.         move.l    conwriteio(pc),a1
  93.         move.l    20(a0),20(a1)
  94.         move.l    24(a0),24(a1)
  95.  
  96.         move.l    window(pc),a0
  97.         move.l    wd_UserPort(a0),a0
  98.         move.b    MP_SIGBIT(a0),Signal.window
  99.         move.l    conreadio(pc),a0
  100.         move.l    MN_REPLYPORT(a0),a0
  101.         move.b    MP_SIGBIT(a0),Signal.console
  102.  
  103.         bsr    sendconreadcmd
  104.         moveq    #0,d0
  105.         rts
  106.  
  107. sendconreadcmd    move.l    4.w,a6
  108.         moveq    #0,d0
  109.         moveq    #0,d1
  110.         move.l    conreadio(pc),a0
  111.         move.l    MN_REPLYPORT(a0),a0
  112.         move.b    MP_SIGBIT(a0),d2
  113.         bset    d2,d1
  114.         LIBCALL    SetSignal
  115.         move.l    conreadio(pc),a1
  116.         clr.b    IO_FLAGS(a1)
  117.         move.l    #256,IO_LENGTH(a1)
  118.         move.l    #conbuf,IO_DATA(a1)
  119.         move.w    #CMD_READ,IO_COMMAND(a1)
  120.         LIBCALL    SendIO
  121.         rts
  122.  
  123. closeconsole    move.l    4.w,a6
  124.         move.l    conreadio(pc),a1
  125.         LIBCALL    CloseDevice
  126. nocondev    move.l    conwriteio(pc),a0
  127.         bsr    FreeIORequest
  128. nodevblock2    move.l    conreadio(pc),a0
  129.         bsr    FreeIORequest
  130. nodevblock1    move.l    intbase(pc),a6
  131.         move.l    window(pc),a0
  132.         LIBCALL    CloseWindow
  133. icnowin        cmp.w    #36,LIB_VERSION(a6)
  134.         bcs.s    icnoscr
  135.         sub.l    a0,a0
  136.         move.l    wbscreen(pc),a1
  137.         LIBCALL    UnlockPubScreen
  138. icnoscr        moveq    #-1,d0
  139.         rts
  140.  
  141. startpronet    moveq    #pnr_Size,d0
  142.         bsr    GetIORequest
  143.         move.l    d0,pronetio
  144.         beq    spnoioreq
  145.         bsr    CreatePort
  146.         move.l    d0,msgport
  147.         beq    spnomsgport
  148.         lea    pronetname,a0
  149.         move.l    unit(pc),d0
  150.         moveq    #0,d1
  151.         move.l    pronetio(pc),a1
  152.         move.w    #$8000,pnr_NetSourcePort(a1)
  153.         move.l    msgport(pc),pnr_MsgPort(a1)
  154.         move.l    4.w,a6
  155.         LIBCALL    OpenDevice
  156.         tst.l    d0
  157.         bne    spnodev
  158.  
  159.         move.l    pronetio(pc),a1
  160.         move.w    pnr_NetSourcePort(a1),pnr_NetDestPort(a1)
  161.  
  162.         move.l    msgport(pc),a0
  163.         move.b    MP_SIGBIT(a0),Signal.pronet
  164.         moveq    #0,d0
  165.         rts
  166.  
  167. stoppronet    move.l    4.w,a6
  168.         move.l    pronetio(pc),a1
  169.         LIBCALL    CloseDevice
  170. spnodev        move.l    msgport(pc),a0
  171.         bsr    DeletePort
  172. spnomsgport    move.l    pronetio(pc),a0
  173.         bsr    FreeIORequest
  174. spnoioreq    moveq    #-1,d0
  175.         rts
  176.  
  177. dec2long    ; konvertiert Dezimalstring ab (a0) zu Longword in D1 !!
  178.         moveq    #0,d1
  179. .loop        moveq    #0,d0
  180.         move.b    (a0)+,d0
  181.         sub.b    #"0",d0
  182.         cmp.b    #9,d0
  183.         bhi.s    .oki
  184.         move.l    d1,d2
  185.         lsl.l    #3,d1
  186.         add.l    d2,d1
  187.         add.l    d2,d1
  188.         add.l    d0,d1
  189.         bra.s    .loop
  190. .oki        rts
  191.  
  192. long2dec    ;Converts Long in d0 to Dec-String in (a0)+
  193.         tst.l    d0
  194.         bne.s    .0
  195.         move.b    #"0",(a0)+
  196.         rts
  197. .0        lea    long2asciitab(pc),a1
  198.         moveq    #9,d1
  199.         moveq    #0,d6
  200. .1        move.l    (a1)+,d2
  201.         move.l    d0,d3
  202.         moveq    #-1,d4
  203. .2        move.l    d3,d5
  204.         sub.l    d2,d3
  205.         cmp.l    d5,d3
  206.         dbhi    d4,.2
  207.         add.l    d2,d3
  208.         move.l    d3,d0
  209.         not.w    d4
  210.         bne.s    .3
  211.         tst.w    d6
  212.         beq.s    .4
  213. .3        st    d6
  214.         add.b    #"0",d4
  215.         move.b    d4,(a0)+
  216. .4        dbra    d1,.1
  217.         rts
  218. long2asciitab    dc.l    1000000000,100000000,10000000,1000000,100000
  219.         dc.l    10000,1000,100,10,1
  220.  
  221. w4mquitflag    dc.w    0
  222. Wait4Message    tst.w    w4mquitflag
  223.         bne    .quit
  224.         clr.w    w4mquitflag
  225.  
  226.         lea    Signals(pc),a3    * auf die Messages
  227.         moveq    #0,d0        * an allen möglichen
  228.         moveq    #numports-1,d1    * Ports warten
  229. .loop1        move.b    (a3),d2
  230.         bmi.s    .0
  231.         bset    d2,d0
  232. .0        addq.w    #6,a3
  233.         dbra    d1,.loop1
  234.         move.l    4.w,a6
  235.         LIBCALL    Wait
  236.                     * entsprechende Routinen
  237.         moveq    #31,d7        * aufrufen
  238. .00        rol.l    d0
  239.         bcc.s    .notthisbit
  240.         lea    Signals(pc),a3
  241.         moveq    #numports-1,d4
  242. .01        cmp.b    (a3),d7
  243.         bne.s    .notthisport
  244.         movem.l    d0/d4/d7/a3,-(sp)
  245.         move.l    2(a3),a3
  246.         jsr    (a3)
  247.         movem.l    (sp)+,d0/d4/d7/a3
  248. .notthisport    addq.w    #6,a3
  249.         dbra    d4,.01
  250. .notthisbit    dbra    d7,.00    
  251.  
  252.         bra    Wait4Message
  253. .quit        rts
  254. Signals:
  255. Signal.window    dc.b    -1,0            ;Signalbit
  256.         dc.l    EvalWindowMessage    ;Entsprechende Routine
  257. Signal.pronet    dc.b    -1,0
  258.         dc.l    ReadFromProNET
  259. Signal.console    dc.b    -1,0
  260.         dc.l    ReadFromConsole
  261. numports    equ    3
  262.  
  263. EvalWindowMessage    ; IDCMP-Flags des Window wurden aufgerufen
  264.         move.l    4.w,a6
  265.         move.l    window(pc),a0
  266.         move.l    wd_UserPort(a0),a0
  267.         LIBCALL    GetMsg
  268.         move.l    d0,a1
  269.         tst.l    d0
  270.         beq.s    .ende
  271.         move.l    $14(a1),d4    ;Class
  272.         move.w    $18(a1),d5    ;Code
  273.         move.w    $1a(a1),d6    ;Qualifier
  274.         move.l    $1c(a1),a4    ;IAddress
  275.         cmp.l    #IDCMP_CLOSEWINDOW,d4
  276.         bne.s    .0
  277.         st    w4mquitflag
  278. .0        LIBCALL    ReplyMsg
  279.         bra.s    EvalWindowMessage
  280. .ende        rts
  281.  
  282. ReadFromProNET        ; Message vom anderen Rechner
  283.         move.l    4.w,a6
  284.         move.l    msgport(pc),a0
  285.         LIBCALL    GetMsg
  286.         tst.l    d0
  287.         beq.s    .ende
  288.         move.l    d0,a3
  289.         move.l    conwriteio(pc),a1
  290.         move.w    #CMD_WRITE,IO_COMMAND(a1)
  291.         move.l    a3,d0
  292.         add.l    #MN_SIZE+4,d0
  293.         move.l    d0,IO_DATA(a1)
  294.         move.l    MN_SIZE(a3),d0
  295.         move.l    d0,IO_LENGTH(a1)
  296.         clr.b    IO_FLAGS(a1)
  297.         LIBCALL    DoIO        ;und auf der Console ausgeben
  298.         move.l    a3,a1
  299.         LIBCALL    ReplyMsg
  300.         bra.s    ReadFromProNET
  301. .ende        rts
  302.  
  303.  
  304. ReadFromConsole        ; Es wurde auf der Console etwas getippt
  305.         move.l    conreadio(pc),a0
  306.         move.l    IO_ACTUAL(a0),d6    ;Anzahl der Bytes
  307.  
  308.         bsr    processconbuf
  309.  
  310.         move.l    conwriteio(pc),a1
  311.         move.w    #CMD_WRITE,IO_COMMAND(a1)
  312.         move.l    #conbuf,IO_DATA(a1)
  313.         move.l    d6,IO_LENGTH(a1)
  314.         clr.b    IO_FLAGS(a1)
  315.         LIBCALL    DoIO            ;auf der Console ausgeben
  316.  
  317.         move.l    pronetio(pc),a1
  318.         move.w    #CMD_WRITE,IO_COMMAND(a1)
  319.         lea    conbuf-4,a0
  320.         move.l    a0,pnr_Data(a1)
  321.         move.l    d6,(a0)
  322.         addq.l    #1,d6
  323.         bclr    #0,d6    ;aufrunden
  324.         addq.l    #4,d6    ;Längenwort !
  325.         move.l    d6,pnr_Length(a1)
  326.         LIBCALL DoIO            ;und auf dem anderen Amiga
  327.         bsr    sendconreadcmd        ;neue Sachen lesen
  328.         rts
  329.  
  330. processconbuf    ; Ein paar Tasten umdefinieren (Cursor, Del etc.)
  331.         ; alte Länge der Daten in D6.l
  332.         ; muß neue Länge in D6.l zurückgeben
  333.         rts
  334.  
  335. ; - Data ------------------------------------------------------------------
  336.  
  337. pronetname    dc.b    "pronet.device",0
  338. consolename    dc.b    "console.device",0
  339. intname        dc.b    "intuition.library",0
  340. wbname        dc.b    "Workbench",0
  341.         even
  342.  
  343. newwindow    dc.w    50,50
  344.         dc.w    400,114
  345.         dc.b    -1,-1
  346.         dc.l    IDCMP_CLOSEWINDOW,$1100e,0,0,wintitle,0,0
  347.         dc.w    -1,-1,-1,-1,$1
  348.  
  349. wintitle    dc.b    "ProNET-Talk! - Starting ProNET..",0
  350. wintitle2    dc.b    "ProNET-Talk! Unit "
  351. wintitle2mod    dc.b    "XXXXXXXX",0
  352.  
  353. ;talkstr        dc.b    "pronet-talk:",0
  354.         even
  355.  
  356. unit        dc.l    0
  357.  
  358. pronetio    dc.l    0
  359. msgport        dc.l    0
  360. intbase        dc.l    0
  361. window        dc.l    0
  362. wbscreen    dc.l    0
  363. conreadio    dc.l    0
  364. conwriteio    dc.l    0
  365.  
  366.         include    "p:include/devio.s"
  367.  
  368.         section    b,bss
  369.  
  370.         ds.b    4
  371. conbuf        ds.b    256
  372.